package com.huangpeng.designmodel.strategy;

import com.huangpeng.designmodel.entity.Receipt;

import java.util.Objects;

/**
 * @Author huangpeng
 * @Title 策略上下文类(策略接口的持有者)
 * @Package
 * @Date 2020/10/21 11:03
 * @Description 策略上下文类(策略接口的持有者)
 * @Version 1.0
 */
public class ReceiptStrategyContext {
    private IReceiptHandleStrategy receiptHandleStrategy;

    /**
     * 设置策略接口
     * @param receiptHandleStrategy
     */
    public void setReceiptHandleStrategy(IReceiptHandleStrategy receiptHandleStrategy) {
        this.receiptHandleStrategy = receiptHandleStrategy;
    }

    public void handleReceipt(Receipt receipt){
        if(Objects.nonNull(receiptHandleStrategy)){
            receiptHandleStrategy.handleReceipt(receipt);
        }
    }
}
